package com.ex3;

public class Producer implements Runnable {//发送方

    private MessageQueue queue;

    public Producer(MessageQueue queue) {
        this.queue = queue;
    }

    public void run() {
        try {
            // 向队列中放入消息
            String message = "Hello, World!";
            queue.putMessage(message);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}

